package com.xcc.mota.utils;

import android.content.Context;
import android.content.res.AssetManager;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;

import java.io.IOException;
import java.io.InputStream;

/**
 * 资源读取
 * Created by Administrator on 2018/1/8.
 */
public class AssetsLoad {
    public AssetsLoad(Context context) {
        this.context = context;
        assetManager = context.getAssets();
    }

    private Context context;
    private AssetManager assetManager;

    public Bitmap getBitmap(String name) {
        try {
            InputStream open = assetManager.open(name);
            return BitmapFactory.decodeStream(open);
        } catch (IOException e) {
            e.printStackTrace();
        }
        return null;
    }
}
